package com.zhike.b2b.expand;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.zhike.b2b.base.BaseAction;
import com.zhike.b2b.model.ProductVo;

@Controller
public class ExpandAction extends BaseAction{
	
	@RequestMapping("/expand/prods.do")
    public String getProds(@RequestParam("page_no") String pageNo,@RequestParam("pos_id") String posId,Model model)
	{
		int size = 5;
		List<ProductVo> lpv = new ArrayList<ProductVo>();
		int pn = Integer.parseInt(pageNo);
		int pid = Integer.parseInt(posId);
		int start = (pn-1)*size;
		int total = exs.queryProducts(lpv,1, pid,start,size);
		model.addAttribute("lpv", lpv);
		model.addAttribute("total", total);
		model.addAttribute("pageNo", pageNo);
		int page = 0;
		if(total%size ==0)
			page = total/size;
		else
			page = total/size+1;
		model.addAttribute("page", page);
		return "/expand/prod_list";
	}
}
